package com.example.administrator.onepagelibrary.view.activity;


import android.content.Intent;
import android.os.Handler;
import android.support.annotation.NonNull;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.RecyclerView.ViewHolder;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.Button;

import com.example.administrator.commonlibrary.bean.GreedaoBean;
import com.example.administrator.commonlibrary.bean.MyBean;
import com.example.administrator.commonlibrary.contract.activity.MaiAcivityContract;
import com.example.administrator.commonlibrary.thirdparty.GreendaoConfig;
import com.example.administrator.commonlibrary.thirdparty.LeakCanaryConfig;
import com.example.administrator.commonlibrary.utils.LogUtil;
import com.example.administrator.commonlibrary.utils.ToastUtils;
import com.example.administrator.commonlibrary.utils.arouter.ARouterUtils;
import com.example.administrator.commonlibrary.utils.rxjava.RxBus;
import com.example.administrator.commonlibrary.wholehelper.GreendaoHelper;
import com.example.administrator.onepagelibrary.R;
import com.example.administrator.onepagelibrary.R2;
import com.example.administrator.onepagelibrary.onebase.OneBaseViewActivity;
import com.example.administrator.onepagelibrary.presenter.activity.MaiActivityPresenter;
import com.github.jdsjlzx.recyclerview.LRecyclerView;
import com.github.jdsjlzx.recyclerview.LRecyclerViewAdapter;

import java.util.ArrayList;
import java.util.List;

import javax.inject.Inject;

import butterknife.BindView;
import butterknife.OnClick;

public class HuadongActivity extends OneBaseViewActivity<MaiAcivityContract.Presenter> implements MaiAcivityContract.View {

    @Inject
    GreendaoHelper greendaoHelper;
    @Inject
    GreendaoHelper greendaoHelper2;
    @Inject
    GreendaoConfig config;
    @Inject
    MaiActivityPresenter presenter;
     @BindView(R2.id.but1)
    Button button;

    @Override
    protected void myOnCreate() {
        button.setText("测试butterknife的点击事件");



    }

    @Override
    protected int onLayout() {
        return R.layout.one_activity_habuyshi;
    }

    @Override
    protected MaiAcivityContract.Presenter initPresenter() {
        return presenter;
    }


    @OnClick({R2.id.but1, R2.id.but2, R2.id.but3, R2.id.leak_canary,  R2.id.set_alias})
    public void onViewClicked(View view) {
        if (view.getId() == R.id.but1) {
            //dagger 实例化单例
            LogUtil.d(greendaoHelper.toString() + "---HuadongActivity--");
            LogUtil.d(greendaoHelper2.toString() + "---HuadongActivity--");

            LogUtil.d(config.toString() + "---config2--");
            GreedaoBean greedaoBean = new GreedaoBean();
            greedaoBean.setMId(1L);
            greendaoHelper.setInster(greedaoBean);
            List<GreedaoBean> list = greendaoHelper.getMusicList();
            ToastUtils.bugToast(list.size() + "--");
        }
        if (view.getId() == R.id.but2) {
            RxBus.getInstance().post(new MyBean());
        }
        if (view.getId() == R.id.but3) {
           ARouterUtils.startActivity(this, "/two/mintent");
        } else if (view.getId() == R.id.leak_canary) {
            handler.post(new Runnable() {
                @Override
                public void run() {
                    try {
                        Thread.sleep(5000);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
            });
            finish();
        } else if (view.getId() == R.id.set_alias) {
          // JPushConfig.setTags(this,5,set);
        }

    }


    @Override
    protected String setPageTitle() {
        return "oneAtivity";
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        LeakCanaryConfig.getRefWatcher(this);
    }

    Handler handler = new Handler() {

    };

}
